package com.pwrd.sframe.support.function;

/**
 * @Auther syc.
 * @Date 2017/3/2 14:10.
 */
public class Func {
    private IFunc func;
    private int paramNum;

    public void use(Object... objects) {

        switch (paramNum) {
            case 0 : ((IFunc0)func).use(); break;
            case 1 : ((IFunc1)func).use(objects[0]); break;
            case 2 : ((IFunc2)func).use(objects[0], objects[1]); break;
            case 3 : ((IFunc3)func).use(objects[0], objects[1], objects[2]); break;
            case 4 : ((IFunc4)func).use(objects[0], objects[1], objects[2], objects[3]); break;
            case 5 : ((IFunc5)func).use(objects[0], objects[1], objects[2], objects[3], objects[4]); break;
            case 6 : ((IFunc6)func).use(objects[0], objects[1], objects[2], objects[3], objects[4], objects[5]); break;
            case 7 : ((IFunc7)func).use(objects[0], objects[1], objects[2], objects[3], objects[4], objects[5], objects[6]); break;
            case 8 : ((IFunc8)func).use(objects[0], objects[1], objects[2], objects[3], objects[4], objects[5], objects[6], objects[7]); break;
            case 9 : ((IFunc9)func).use(objects[0], objects[1], objects[2], objects[3], objects[4], objects[5], objects[6], objects[7], objects[8]); break;
        }
    }

    public Func(IFunc0 function) {
        func = function;
        paramNum = 0;
    }

    public Func(IFunc1 function) {
        func = function;
        paramNum = 1;
    }

    public Func(IFunc2 function) {
        func = function;
        paramNum = 2;
    }

    public Func(IFunc3 function) {
        func = function;
        paramNum = 3;
    }

    public Func(IFunc4 function) {
        func = function;
        paramNum = 4;
    }

    public Func(IFunc5 function) {
        func = function;
        paramNum = 5;
    }

    public Func(IFunc6 function) {
        func = function;
        paramNum = 6;
    }

    public Func(IFunc7 function) {
        func = function;
        paramNum = 7;
    }
    public Func(IFunc8 function) {
        func = function;
        paramNum = 8;
    }

    public Func(IFunc9 function) {
        func = function;
        paramNum = 9;
    }

}

